package cn.village.service.impl;
import cn.village.dao.LeaseContractMapper;
import cn.village.entity.LeaseContract;
import cn.village.service.LeaseContractService;
import org.springframework.stereotype.Service;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.ArrayList;
import java.util.HashMap;

@Service
public class LeaseContractServiceImpl implements LeaseContractService {

    @Resource
    private LeaseContractMapper leaseContractMapper;

    public LeaseContract getLeaseContractById(String id)throws Exception{
        return leaseContractMapper.getLeaseContractById(id);
    }

    public List<LeaseContract>	getLeaseContractListByMap(Map<String,Object> param)throws Exception{
        return leaseContractMapper.getLeaseContractListByMap(param);
    }

    public Integer getLeaseContractCountByMap(Map<String,Object> param)throws Exception{
        return leaseContractMapper.getLeaseContractCountByMap(param);
    }

    public Integer qdtxAddLeaseContract(LeaseContract leaseContract)throws Exception{
            //leaseContract.setCreatedTime(new Date());
            return leaseContractMapper.insertLeaseContract(leaseContract);
    }

    public Integer qdtxModifyLeaseContract(LeaseContract leaseContract)throws Exception{
        //leaseContract.setUpdatedTime(new Date());
        return leaseContractMapper.updateLeaseContract(leaseContract);
    }

    public Integer qdtxDeleteLeaseContractById(String id)throws Exception{
        return leaseContractMapper.deleteLeaseContractById(id);
    }

    public Integer qdtxBatchDeleteLeaseContract(String ids)throws Exception{
        Map<String,List<String>> param=new HashMap<String,List<String>>();
        String[] paramArrays=ids.split(",");
        List<String> idList=new ArrayList<String>();
            for (String temp:paramArrays){
                idList.add(temp);
            }
        param.put("ids",idList);
        return leaseContractMapper.batchDeleteLeaseContract(param);
    }


}
